/**
 * 
 */
package dms.presentation.action.sys;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;

import dms.dto.SystemAdministratorDTO;
import dms.model.role.wrapper.SystemAdministratorWrapper;
import dms.util.Constant;
import dms.util.ContextUtil;

/**
 * 修改系统管理员自己的信息
 * 失败返回重输入页面
 * 成功返回个人信息页面
 * @author 李健
 *
 */
public class ModifyPersonalInfoAction extends Action {
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		SystemAdministratorDTO saForm = (SystemAdministratorDTO) form;
		ApplicationContext appContext = ContextUtil.getContext();
		SystemAdministratorWrapper saWrapper = (SystemAdministratorWrapper) appContext.getBean("systemAdministratorWrapper");
		
		long id = saWrapper.getSystemAdministrator().getId();
		saForm.setId(id);
		
		try {
			saWrapper.modifyPersonalInfo(saForm);
		} catch (Exception e) {
			return mapping.getInputForward();
		}
		
		
		return mapping.findForward(Constant.SUCCESS);
	}
}
